using B.S.XZYData.Api.Wrter.Application.Command.WorkTask;
using B.S.XZYData.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;

namespace B.S.XZYData.Api.Wrter.Controllers
{
    /// <summary>
    /// 任务写入接口
    /// </summary>
    [ApiController]
    [Route("api/[controller]/[action]")]
    public class WorkTaskController : ControllerBase
    {
        private readonly IMediator _mediator;
        
        public WorkTaskController(IMediator mediator) 
        { 
            _mediator = mediator; 
        }

        /// <summary>
        /// 更新任务
        /// </summary>
        [HttpPut]
        public Task<ApiResult<int>> Update([FromBody] UpdateWorkTaskCommand request)
        {
            return _mediator.Send(request);
        }

        /// <summary>
        /// 批量删除任务
        /// </summary>
        [HttpDelete]
        public Task<ApiResult<int>> BatchDelete([FromBody] BatchDeleteWorkTaskCommand request)
        {
            return _mediator.Send(request);
        }
    }
} 